﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DevTrends.MvcDonutCaching;
using ECG.Common;
using ECG.DAL;
using ECG.WebUI.Models;

namespace ECG.WebUI.Controllers
{
    public class ProviderHomeController : Controller
    {
        //
        // GET: /ProviderHome/

        //chua lam
        public ActionResult Index()
        {

            return View();
        }
        [DonutOutputCache(Duration = 3600, VaryByParam = "categoryId;categoryName")]
        public ActionResult ViewProviderHomeByCate(string categoryId = "", string categoryName = "")
        {
            ViewBag.Cate = categoryId;
            ViewBag.CateName = categoryName;
            return View();
        }

        //------------------------------------------------------------------
        //Thuong hieu noi bat nhat theo mot danh muc nao do
        public ActionResult ViewProviderHotByCate(string categoryId = "")
        {

            var data = ProviderDb.GetHotByCate(categoryId) ?? new List<ProviderListHotCateDto>();

            return PartialView(data);
        }

        //Hien thi thuong hieu theo danh muc
        public ActionResult ViewProviderListByCate(string categoryId = "")
        {
            var data = ProviderDb.GetHotByCateList(categoryId) ?? new List<ProviderListHotCateDto>();
            ViewBag.CategoryId = categoryId;
            return PartialView(data);
        }

        public PartialViewResult GetProviderByLetter(string categoryId, string letter, int page = 1)
        {
            var model = ProviderDb.GetAllProviderByLetter(categoryId, letter) ?? new List<ProviderListByLetterDto>();
            return PartialView(model);
        }

        public JsonResult GetTotalProviderByCate(string cate)
        {
            var result = ProviderDb.GetTotalProviderBycate(cate);
            return Json(result, JsonRequestBehavior.AllowGet);
        }
    }
}
